﻿Public Class FichaCliente
    Public Bd As BD
    Private Sub ButtonBuscar_Click(sender As Object, e As EventArgs) Handles ButtonBuscar.Click
        Dim MiCliente As Cliente


        If (Bd.CargarCliente(TextBoxDni.Text, MiCliente)) Then

            TextBoxNombre.Text = MiCliente.Nombre()
            TextBoxTelefono.Text = MiCliente.Telefono()
            TextBoxEmail.Text = MiCliente.Email()
            TextBoxFacebook.Text = MiCliente.Facebook()
            TextBoxTwitter.Text = MiCliente.Twitter()
            If (MiCliente.Whatssapp()) Then
                RadioButtonSi.Checked = True
            Else
                RadioButtonNo.Checked = True
            End If

            Dim Adapter As Data.SQLite.SQLiteDataAdapter = Bd.CargarReservasCliente(MiCliente)

            Dim Ds As New DataSet()
            Ds.Reset()

            Dim Dt As New DataTable()
            Adapter.Fill(Ds)

            Dt = Ds.Tables(0)

            DataGridView1.DataSource = Dt
            DataGridView1.Columns(0).Visible = False


        Else
            MessageBox.Show("Cliente no encontrado")
        End If
    End Sub

    Private Sub FichaCliente_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Bd = Principal.Bd()
    End Sub

    Private Sub ButtonModificar_Click(sender As Object, e As EventArgs) Handles ButtonModificar.Click
        Dim MiCliente As New Cliente(TextBoxDni.Text, TextBoxNombre.Text, TextBoxTelefono.Text, TextBoxEmail.Text, RadioButtonSi.Checked, TextBoxFacebook.Text, TextBoxTwitter.Text)
        If (Bd.ModificarCliente(MiCliente)) Then
            MessageBox.Show("Cliente actualizdo correctamente")
        End If
    End Sub
End Class